#include "CPathManager.h"
#include <QDebug>

CPathManager::CPathManager(QObject *parent) : QObject(parent)
{

}

QString CPathManager::appDataPath()
{
    return QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation);
}

QString CPathManager::sessionDataPath()
{
    QString strPath = appDataPath() + "/Session";
    QDir dir(strPath);
    if(!dir.exists()){
        if(!dir.mkpath(strPath)){
            qWarning()<<strPath<<" 会话目录创建失败!";
        }
    }
    return strPath;
}

QString CPathManager::globalDataFileName()
{
    return QString("%1/%2.json").arg(sessionDataPath()).arg("sessions");
}

QString CPathManager::sessionDataFileName(QString strId)
{
    return QString("%1/%2.json").arg(sessionDataPath()).arg(strId);
}
